<?php
session_start(); 

 function isSession($var) {
   return isset($_SESSION[$var]) && $_SESSION[$var];
 }

function unsetSession($var) {
  $_SESSION[$var] = false;
  unset($_SESSION[$var]);
}

// View for iphones
if (isset($_REQUEST['iphone'])) {
  $_SESSION['iphone'] = TRUE;
  unsetSession('table');
  unsetSession('alphabetical');
 }

// View for iphones
if (isset($_REQUEST['map'])) {
  $_SESSION['map'] = TRUE;
  unsetSession('alphabetical');
  unsetSession('table');
 }

// Tabular view
if (isset($_REQUEST['table'])) {
  $_SESSION['table'] =  TRUE;
  unsetSession('alphabetical');
  unsetSession('iphone');
 }

// Alphabetical view
if (isset($_REQUEST['alphabetical'])) {
  $_SESSION['alphabetical'] = TRUE;
  unsetSession('table');
  unsetSession('iphone');
 }

// Search view
if (isset($_REQUEST['search'])) {
  $_SESSION['search'] = TRUE;
  unsetSession('alphabetical');
  unsetSession('table');
 }

// Normal view
if (isset($_REQUEST['list'])) {
  $_SESSION['list'] = TRUE;
  unsetSession('iphone');
 }

// Unset the iphone view
if (isset($_REQUEST['noiphone']) || isset($_REQUEST['map'])) {
  unsetSession('iphone');
 }

?>